let siteTitle = "";
let pageTitle = "";

function setTitle() {
    if (siteTitle && pageTitle) {
        document.title = `${pageTitle} - ${siteTitle}`;
    } else if (siteTitle && !pageTitle) {
        document.title = siteTitle;
    } else if (!siteTitle && pageTitle) {
        document.title = pageTitle;
    } else {
        document.title = "loading...";
    }
}

export function setSiteTitle(title) {
    if (pageTitle === "页面找不到") {
        document.title = pageTitle;
        return;
    }
    siteTitle = title;
    setTitle();
}

export function setPageTitle(title) {
    if (title === "页面找不到") {
        document.title = title;
        return;
    }
    pageTitle = title;
    setTitle();
}
